package com.xiaochong.tir.trades.rabbit;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * Created by org on 2018/6/15.
 * 币安队列绑定
 */
@Configuration
@Component
public class LbankQueenConfig {
    /**
     * 配置消息交换机
     * 针对消费者配置
     FanoutExchange: 将消息分发到所有的绑定队列，无routingkey的概念
     HeadersExchange ：通过添加属性key-value匹配
     DirectExchange:按照routingkey分发到指定队列
     TopicExchange:多关键字匹配
     */
    @Bean
    public DirectExchange LbankNodeAPIExchange() {
        return new DirectExchange(ExchangeQueue.Exchange.EX_NODE_API_MQ, true, false);
    }
    @Bean
    public Queue queueTradesLbankBtcAction(){
        return new Queue(LbankMqQueue.QUEUE_TRADES_LBANK_BTC, true);
    }
    @Bean
    public Binding bindingTradesLbankBtcAction(){
        return BindingBuilder.bind(queueTradesLbankBtcAction()).to(LbankNodeAPIExchange()).with(LbankMqQueue.QUEUE_TRADES_LBANK_BTC);
    }

    @Bean
    public Queue queueTradesLbankEthAction(){
        return new Queue(LbankMqQueue.QUEUE_TRADES_LBANK_ETH, true);
    }
    @Bean
    public Binding bindingTradesLbankEthAction(){
        return BindingBuilder.bind(queueTradesLbankEthAction()).to(LbankNodeAPIExchange()).with(LbankMqQueue.QUEUE_TRADES_LBANK_ETH);
    }

    @Bean
    public Queue queueTradesLbankQtumAction(){
        return new Queue(LbankMqQueue.QUEUE_TRADES_LBANK_QTUM, true);
    }
    @Bean
    public Binding bindingTradesLbankQtumAction(){
        return BindingBuilder.bind(queueTradesLbankQtumAction()).to(LbankNodeAPIExchange()).with(LbankMqQueue.QUEUE_TRADES_LBANK_QTUM);
    }

    @Bean
    public Queue queueTradesLbankUsdtAction(){
        return new Queue(LbankMqQueue.QUEUE_TRADES_LBANK_USDT, true);
    }
    @Bean
    public Binding bindingTradesLbankUsdtAction(){
        return BindingBuilder.bind(queueTradesLbankUsdtAction()).to(LbankNodeAPIExchange()).with(LbankMqQueue.QUEUE_TRADES_LBANK_USDT);
    }

    @Bean
    public Queue queueTradesLbankVetAction(){
        return new Queue(LbankMqQueue.QUEUE_TRADES_LBANK_VET, true);
    }
    @Bean
    public Binding bindingTradesLbankVetAction(){
        return BindingBuilder.bind(queueTradesLbankVetAction()).to(LbankNodeAPIExchange()).with(LbankMqQueue.QUEUE_TRADES_LBANK_VET);
    }
}
